package com.pdf.pdfserver.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author songfz
 * @Description 文件后缀名称
 * @Date 2022/1/4
 */
public enum FileSuffixEnum {

    DOC("doc"),
    DOCX("docx"),
    PDF("pdf"),
    TXT("txt"),
    PPT("ppt"),
    PPTX("pptx"),
    XLS("xls"),
    XLSX("xlsx");

    private String value;

    static Map<String, FileSuffixEnum> map = new HashMap<>();

    FileSuffixEnum(String value) {
        this.value = value;
    }

    static {
        for (FileSuffixEnum suffixEnum : values()) {
            map.put(suffixEnum.value, suffixEnum);
        }
    }

    public static FileSuffixEnum getSuffix(String fileName) {
        String suffix = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
        return map.get(suffix);
    }
}
